//
//  PhotoCommentViewController.m
//  Gruphoto
//
//  Created by Thao Nguyen Huy on 1/12/13.
//  Copyright (c) 2013 CNC Software. All rights reserved.
//

#import "MakeCommentViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "GruphotoAppDelegate.h"

@interface MakeCommentViewController ()

@end

@implementation MakeCommentViewController
@synthesize commentTextView, commentView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.view.backgroundColor = [UIColor colorWithRed:226/255.0 green:231/255.0 blue:237/255.0 alpha:1.0];        
		UIImageView *titleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"title_gruphoto.png"]];
		self.navigationItem.titleView = titleImageView;
		[titleImageView release];
        
        UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [cancelButton setBounds:CGRectMake(0, 0, 51, 30)];
        [cancelButton setBackgroundImage:[UIImage imageNamed:@"button_cancel.png"] forState:UIControlStateNormal];
        [cancelButton addTarget:self action:@selector(cancelButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *cancelButtonItem = [[UIBarButtonItem alloc] initWithCustomView:cancelButton];
        self.navigationItem.leftBarButtonItem = cancelButtonItem;
        [cancelButtonItem release];
        
        UIButton *addButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [addButton setBounds:CGRectMake(0, 0, 51, 30)];
        [addButton setBackgroundImage:[UIImage imageNamed:@"button_add.png"] forState:UIControlStateNormal];
        [addButton addTarget:self action:@selector(addButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithCustomView:addButton];
        self.navigationItem.rightBarButtonItem = addButtonItem;
        [addButtonItem release];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    commentView.layer.masksToBounds = YES;
    commentView.layer.cornerRadius = 10;
    [commentTextView becomeFirstResponder];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    self.commentTextView = nil;
    self.commentView = nil;
}

- (void)dealloc {
    [commentTextView release];
    [commentView release];
    [super dealloc];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Action methods
- (IBAction)cancelButtonPressed:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)addButtonPressed:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

@end
